{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}/Users/shelley/Dropbox/Projects/Senegal/Senegal Nigeria Education and Leaders/Senegal Replication Files/do files/0_plots.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 5 Jul 2023, 17:24:19

{com}. do "/var/folders/hc/sj03f0796ql87mzypb773sp40000gn/T//SD90270.000000"
{txt}
{com}. 
. clear all
{res}{txt}
{com}. capture cd "~/Dropbox/Projects/Senegal/Senegal Nigeria Education and Leaders/Senegal Replication Files"
{txt}
{com}. 
. * create dataset
. set more off
{txt}
{com}. set matsize 11000
{txt}{bf:set matsize} ignored.
{p 4 4 2}
Matrix sizes are no longer limited by
{bf:c(matsize)} in modern Statas.
Matrix sizes are now limited by edition of Stata.
See {help limits} for more details.
{p_end}

{com}. do "do files/create dataset"
{txt}
{com}. 
. quietly {c -(}
{txt}
{com}. 
{txt}end of do-file

{com}. 
. * controls
. global controls i.birthyear_control i.year_survey_control post3 treat2_10_inc wolof-others male urbrur2
{txt}
{com}. global controls2 i.year_survey_control wolof-others male urbrur2
{txt}
{com}. 
. 
. * First stage
. 
. gen indiv2 = school4
{txt}(1,235 missing values generated)

{com}. replace indiv2 = 1 if school4 == 2
{txt}(2,134 real changes made)

{com}. 
. gen indiv3 = school4
{txt}(1,235 missing values generated)

{com}. recode indiv3 (1=0)(2=1)
{txt}(2,915 changes made to {bf:indiv3})

{com}. 
. gen indiv4 = school
{txt}(1,235 missing values generated)

{com}. recode indiv4 (1/4 = 0) (5/7 = 1)
{txt}(5,912 changes made to {bf:indiv4})

{com}. 
. est clear
{txt}
{com}. 
. label var school4 "School index"
{txt}
{com}. label var indiv2 "Incomplete primary school"
{txt}
{com}. label var indiv3 "Completed primary school"
{txt}
{com}. label var indiv4 "Incomplete secondary school"
{txt}
{com}. 
. 
. *****************
. ***   Plots   ***
. *****************
. 
. do "do files/background plots"
{txt}
{com}. 
. 
. set scheme s1mono
{txt}
{com}. 
. ****************************
. ***   Background plots   ***
. ****************************
. 
. 
. gen school5 = 0 if school != .
{txt}(1,235 missing values generated)

{com}. replace school5 = 1 if school >=5 & school != .
{txt}(1,726 real changes made)

{com}. 
. 
. *** 2005-2008
. 
. gen sat_dem = satisfaction_democracy
{txt}(1,942 missing values generated)

{com}. recode sat_dem (1/2=1)
{txt}(1,096 changes made to {bf:sat_dem})

{com}. label var sat_dem "Satisfaction with Senegal's Democracy"
{txt}
{com}. 
. gen how_dem = how_democratic
{txt}(1,758 missing values generated)

{com}. recode how_dem (1/2=1)
{txt}(1,357 changes made to {bf:how_dem})

{com}. label var how_dem "Believe That Senegal is a Functioning Democracy"
{txt}
{com}. 
. 
. global vars sat_dem how_dem
{txt}
{com}. 
. foreach var of varlist $vars {c -(}
{txt}  2{com}.         egen mean_`var' = mean(`var') if birthyear_control >= 1970 & birthyear_control <= 1997, by(year)
{txt}  3{com}.         egen mean1_`var' = mean(`var') if birthyear_control >= 1970 & birthyear_control <= 1997 & school5 == 0, by(year)
{txt}  4{com}.         egen mean2_`var' = mean(`var') if birthyear_control >= 1970 & birthyear_control <= 1997 & school5 == 1, by(year)
{txt}  5{com}. 
. {c )-}
{txt}(3,787 missing values generated)
(5,073 missing values generated)
(5,873 missing values generated)
(3,787 missing values generated)
(5,073 missing values generated)
(5,873 missing values generated)

{com}. 
. foreach var of varlist $vars {c -(}
{txt}  2{com}.                 local vlab : variable label `var'
{txt}  3{com}.                 twoway ///
>                 (line mean_`var' year, lcolor(gs0)) ///
>                 (line mean1_`var' year, lcolor(gs12) lpattern(dash)) ///
>                 (line mean2_`var' year, lcolor(gs0) lpattern(dash)), ///
>                 legend(order(1 2 3) label(1 "Aggregate") label(2 " Primary or lower") label(3 "Some secondary")) ///
>                 title("`vlab'") ytitle("") xtitle("Survey Year") xlabel(2002 2005 2008 2013 2014)
{txt}  4{com}.                 quietly: graph export "plots/`vlab'.pdf", replace
{txt}  5{com}. {c )-}
{res}{txt}
{com}. 
. 
. 
. 
. gen trust_ec = trust_EC
{txt}(2,489 missing values generated)

{com}. recode trust_EC (1/3=1)
{txt}(2,854 changes made to {bf:trust_EC})

{com}. 
. gen elections = elections_free_fair
{txt}(2,739 missing values generated)

{com}. recode elections (1=0) (2/4=1)
{txt}(4,408 changes made to {bf:elections})

{com}. 
. global vars trust_ec elections
{txt}
{com}. label var trust_ec "Trust Electoral Commission"
{txt}
{com}. label var elections "Elections are Free and Fair"
{txt}
{com}. 
. foreach var of varlist $vars {c -(}
{txt}  2{com}.         egen mean_`var' = mean(`var') if birthyear_control >= 1970 & birthyear_control <= 1997, by(year)
{txt}  3{com}.         egen mean1_`var' = mean(`var') if birthyear_control >= 1970 & birthyear_control <= 1997 & school5 == 0, by(year)
{txt}  4{com}.         egen mean2_`var' = mean(`var') if birthyear_control >= 1970 & birthyear_control <= 1997 & school5 == 1, by(year)
{txt}  5{com}. {c )-}
{txt}(3,787 missing values generated)
(5,073 missing values generated)
(5,873 missing values generated)
(4,303 missing values generated)
(5,420 missing values generated)
(6,039 missing values generated)

{com}. 
. 
. foreach var of varlist $vars {c -(}
{txt}  2{com}.                 local vlab : variable label `var'
{txt}  3{com}.                 twoway ///
>                 (line mean_`var' year, lcolor(gs0)) ///
>                 (line mean1_`var' year, lcolor(gs12) lpattern(dash)) ///
>                 (line mean2_`var' year, lcolor(gs0) lpattern(dash)), ///
>                 legend(order(1 2 3) label(1 "Aggregate") label(2 " Primary or lower") label(3 "Some secondary")) ///
>                 title("`vlab'") ytitle("") xtitle("Survey Year") xlabel(2002 2005 2008 2013 2014)
{txt}  4{com}.                 quietly: graph export "plots/`vlab'.pdf", replace
{txt}  5{com}. {c )-}
{res}{txt}
{com}. 
. 
. 
. ***********************************************
. ***   Diff in diff plots for Appendix A.4   ***
. ***********************************************
. 
. bys birthyear: gen cohort_weight = _N
{txt}
{com}. 
. foreach var of varlist school4 indiv2 indiv3 indiv4 {c -(}
{txt}  2{com}.         
.         local vlab : variable label `var'
{txt}  3{com}.         
.         bys birthyear: egen m1_`var' =mean(`var') if treat2_10_inc <= med_treat2_10_inc & treat2_10_inc != .
{txt}  4{com}.         bys birthyear: egen m2_`var' =mean(`var') if treat2_10_inc > med_treat2_10_inc & treat2_10_inc != .
{txt}  5{com}.         
.         twoway (scatter m1_`var' birthyear if birthyear >= 1970 & birthyear <= 1997 [w=cohort_weight], color(gs9) msize(vsmall)) ///
>   (scatter m2_`var' birthyear if birthyear >= 1970 & birthyear <= 1997 [w=cohort_weight], color(black) msize(vsmall)) ///
>                 (lpoly m1_`var' birthyear if birthyear >= 1970 & birthyear < 1986, bwidth(2) lcolor(gs9) clwidth(medthick)) ///
>                 (lpoly m2_`var' birthyear if birthyear >= 1970 & birthyear < 1986, bwidth(2) lcolor(black) clwidth(medthick)) /// 
>                 (lpoly m1_`var' birthyear if birthyear >= 1986 & birthyear <= 1997, bwidth(2) lcolor(gs9) clwidth(medthick)) ///
>                 (lpoly m2_`var' birthyear if birthyear >= 1986 & birthyear <= 1997, bwidth(2) lcolor(black) clwidth(medthick)), ///
>                 subtitle(, color(black) fcolor(white) lcolor(white)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) xtitle("Year of birth") legend(nobox region(fcolor(white) margin(zero) lcolor(white)) ///
>                 lab(3 "Below-median intensity") lab(6 "Above-median intensity") order(3 6)) ylab(, nogrid) ytitle("Proportion") title("`vlab'") xline(1986, lcolor(black) lpattern(dash)) xlabel(1970(5)1995)
{txt}  6{com}.         drop m1* m2*
{txt}  7{com}.         local y `"`y' "`var'""' 
{txt}  8{com}.         quietly: graph export "plots/`vlab'.pdf", replace
{txt}  9{com}.         
. {c )-}
{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}
{com}. 
. 
. label var economic_index "Economic index"
{txt}
{com}. label var information "Information index"
{txt}
{com}. label var participation_index "Participation Index"
{txt}
{com}. label var dem_checks_on_pres "Checks on President"
{txt}
{com}. 
. foreach var of varlist economic_index information participation_index dem_checks_on_pres {c -(}
{txt}  2{com}.         
.         local vlab : variable label `var'
{txt}  3{com}.         
.         bys birthyear: egen m1_`var' =mean(`var') if treat2_10_inc <= med_treat2_10_inc & treat2_10_inc != .
{txt}  4{com}.         bys birthyear: egen m2_`var' =mean(`var') if treat2_10_inc > med_treat2_10_inc & treat2_10_inc != .
{txt}  5{com}.         
.         twoway (scatter m1_`var' birthyear if birthyear >= 1970 & birthyear <= 1997 [w=cohort_weight], color(gs9) msize(vsmall)) ///
>   (scatter m2_`var' birthyear if birthyear >= 1970 & birthyear <= 1997 [w=cohort_weight], color(black) msize(vsmall)) ///
>                 (lpoly m1_`var' birthyear if birthyear >= 1970 & birthyear < 1986, bwidth(2) lcolor(gs9) clwidth(medthick)) ///
>                 (lpoly m2_`var' birthyear if birthyear >= 1970 & birthyear < 1986, bwidth(2) lcolor(black) clwidth(medthick)) /// 
>                 (lpoly m1_`var' birthyear if birthyear >= 1986 & birthyear <= 1997, bwidth(2) lcolor(gs9) clwidth(medthick)) ///
>                 (lpoly m2_`var' birthyear if birthyear >= 1986 & birthyear <= 1997, bwidth(2) lcolor(black) clwidth(medthick)), ///
>                 subtitle(, color(black) fcolor(white) lcolor(white)) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) xtitle("Year of birth") legend(nobox region(fcolor(white) margin(zero) lcolor(white)) ///
>                 lab(3 "Below-median intensity") lab(6 "Above-median intensity") order(3 6)) ylab(, nogrid) ytitle("Scale") title("`vlab'") xline(1986, lcolor(black) lpattern(dash)) xlabel(1970(5)1995)
{txt}  6{com}.         drop m1* m2*
{txt}  7{com}.         local y `"`y' "`var'""' 
{txt}  8{com}.         quietly: graph export "plots/`vlab'.pdf", replace
{txt}  9{com}.         
. {c )-}
{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}(4,294 missing values generated)
(4,301 missing values generated)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}
{com}. 
. 
. 
. 
. 
{txt}end of do-file

{com}. 
{txt}end of do-file

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}/Users/shelley/Dropbox/Projects/Senegal/Senegal Nigeria Education and Leaders/Senegal Replication Files/do files/0_plots.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res} 5 Jul 2023, 17:24:51
{txt}{.-}
{smcl}
{txt}{sf}{ul off}